package com.vincent.kdp.Activity;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.TextView;

import com.vincent.kdp.PostUrl;
import com.vincent.kdp.R;
import com.vincent.kdp.js.GoodsDetailOperator;
import com.vincent.kdp.js.ShopCartOperator;
import com.vincent.kdp.view.LoadingWebChromeClient;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class ShopCartOkActivity extends Activity {

    @Bind(R.id.back_img)
    ImageView backImg;
    @Bind(R.id.toolbar_center_tv)
    TextView toolbarCenterTv;
    @Bind(R.id.webView)
    WebView webView;
    private String ids;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_shop_cart_ok);

        ButterKnife.bind(this);
        toolbarCenterTv.setText("购物车结算");
        ids = getIntent().getStringExtra("ids");
        System.out.println("ids----"+ids);
        initializeWebView();
    }

    @SuppressLint({ "NewApi", "SetJavaScriptEnabled" })
    private void initializeWebView(){
        webView.addJavascriptInterface(new ShopCartOperator(ShopCartOkActivity.this,ids),
                "Consume");
        try {
            //String url = "file:///android_asset/LoginJs/login.html";
            String url= PostUrl.SERVICE_URL+"/H5/addConsume/addConsume.html";
            WebSettings webSettings = webView.getSettings();
            webSettings.setJavaScriptEnabled(true);
            webSettings.setAllowFileAccess(true);
            webSettings.setAllowFileAccessFromFileURLs(true);
            webSettings.setBuiltInZoomControls(false);
            webSettings.setSupportZoom(false);
            webSettings.setDisplayZoomControls(false);
            this.webView.loadUrl(url);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    @OnClick(R.id.back_img)
    public void onViewClicked() {
        finish();
    }
}
